package com.ruoyi.business.factory;

import cn.hutool.extra.spring.SpringUtil;
import com.ruoyi.business.factory.llm.AbstractUserTypeTemplate;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;

import java.util.Objects;

/**
 * 用户类型模板工厂
 *
 * @author 99
 * @className AiFactory
 * @description TODO
 * @date 2023/4/22 11:25
 */
public class UserTypeTemplateFactory {

    public static AbstractUserTypeTemplate getInstance(UserType en) {
        try {
            AbstractUserTypeTemplate template = SpringUtil.getBean(
                Objects.requireNonNull(en.getUserType()), AbstractUserTypeTemplate.class
            );
            return template;
        } catch (NoSuchBeanDefinitionException e) {
            throw new ServiceException("用户类型模版不存在");
        }
    }
}
